<?php
namespace api\controllers;

use common\helpers\WechatHelper;
use Yii;
use yii\web\Controller;
use yii\web\NotFoundHttpException;

/**
 * Class SiteController
 * @package wechat\controllers
 * @author jianyan74 <751393839@qq.com>
 */
class AppController extends Controller
{
    /**
     * @return array
     */
//    public function actions()
//    {
//        return [
//            'error' => [
//                'class' => 'yii\web\ErrorAction',
//            ],
//        ];
//    }

    /**
     * Displays homepage.
     *
     * @return string
     */
    public function actionIndex()
    {
        $request = Yii::$app->request;

        if (WechatHelper::verifyToken($request->get('signature'), $request->get('timestamp'), $request->get('nonce')))
        {

            echo $request->get('echostr');exit;

        }

        throw new NotFoundHttpException('签名验证失败.');
    }


}
